package com.controller;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import sun.org.mozilla.javascript.internal.regexp.SubString;
import com.util.ConfigUtil;

import com.util.BODY;
import com.util.Constant;
import com.util.HttpRequest;
import com.util.JSONUtil;
import com.util.OpenKey;
import com.util.ReadConfig;
import com.util.SessionInfo;
import com.util.Util;

/**
 * 单位编辑汇缴清册
 * @author 
 */
@Controller
@RequestMapping("/dwbjhjqccontroller")
public class dwbjhjqccontroller {

	private static final Logger logger = Logger.getLogger(dwbjhjqccontroller.class);
	Map map  = new HashMap();
	List list = new ArrayList();
	  
	@RequestMapping("/test1")
	@ResponseBody
	//汇缴清册编辑
	public String entryinterface(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String id,String start,String end,String XINGMING,String ZJHM) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		String JCQK="缴存";
		Map reqMap = new HashMap();
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ126");
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setDWZH(sessionIn.getDWZH());
		b.setRQJCQK("全部");
		reqMap.put("BODY",b);
		b.setXINGMING(XINGMING);
		b.setZJHM(ZJHM);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		List retlist=new ArrayList();
		if(retMap.get("RETURNCODE").equals("100")){
		retMap = (Map) retMap.get("body");
    	 retlist = (List)retMap.get("RETDATA");
		for (int i = 0; i < retlist.size(); i++) {		
			Map map = (Map) retlist.get(i);
			map.put("DWMC", retMap.get("DWMC").toString());	
		}
		}
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
			List listttmp = new ArrayList();
			map.put("code", 0); 
			map.put("msg", resMap.get("RETURNDESC"));
			map.put("data",retlist);
			response.setHeader("Content-type", "text/html;charset=UTF-8");
			response.setCharacterEncoding("UTF-8");
			String jsonString = JSONUtil.ToJsongString2(map);
			PrintWriter pw = response.getWriter();
			pw.write(jsonString);
		
	}
		return null;
	}
	@RequestMapping("/test2")
	@ResponseBody
	public String rytj(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String id,String start,String end) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		
		Map reqMap = new HashMap();
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ126");
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setDWZH(sessionIn.getDWZH());
		b.setRQJCQK("缴存");
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		List retlist=new ArrayList();
		if(retMap.get("RETURNCODE").equals("100")){
		retMap = (Map) retMap.get("body");
    	 retlist = (List)retMap.get("RETDATA");
		for (int i = 0; i < retlist.size(); i++) {	
			Map map = (Map) retlist.get(i);
			map.put("DWZH", retMap.get("DWZH").toString());			
		}
		}
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
				//List resList = JSONUtil.toList(resMap.get("body").toString());
				//map.put("count", resList.size());
				map.put("code", 0); 
				map.put("msg", resMap.get("RETURNDESC"));
				map.put("data", retlist);
				
				response.setHeader("Content-type", "text/html;charset=UTF-8");
				response.setCharacterEncoding("UTF-8");
				String jsonString = JSONUtil.ToJsongString2(map);
				PrintWriter pw = response.getWriter();
				pw.write(jsonString);
		}
		return null;
	}
	@RequestMapping("/test3")
	@ResponseBody
	public String hfjc(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String id,String start,String end) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		
		Map reqMap = new HashMap();
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ126");
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setDWZH(sessionIn.getDWZH());
		b.setRQJCQK("停缴");
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		if(retMap.get("RETURNCODE").equals("100")){
		retMap = (Map) retMap.get("body");
    	List retlist = (List)retMap.get("RETDATA");
		for (int i = 0; i < retlist.size(); i++) {
			
			Map map = (Map) retlist.get(i);
			map.put("DWZH", retMap.get("DWZH").toString());
			   
			
		}
		}

		
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
			Map retMap1 = (Map) resMap.get("body");
				//List resList = JSONUtil.toList(resMap.get("body").toString());
				//map.put("count", resList.size());
				map.put("code", 0); 
				map.put("msg", resMap.get("RETURNDESC"));
				map.put("data", retMap1.get("RETDATA"));
				
				response.setHeader("Content-type", "text/html;charset=UTF-8");
				response.setCharacterEncoding("UTF-8");
				String jsonString = JSONUtil.ToJsongString2(map);
				PrintWriter pw = response.getWriter();
				pw.write(jsonString);
		}
		return null;
	}
	@RequestMapping("/bj")
	@ResponseBody
	public String bj(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String GRZH,String JCQK,String XINGMING,String ZJHM) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		Map reqMap = new HashMap();
		//接口编码
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ126");
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setDWZH(sessionIn.getDWZH());
		b.setRQJCQK(JCQK);
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		if(retMap.get("RETURNCODE").equals("100")){
		retMap = (Map) retMap.get("body");
    	List retlist = (List)retMap.get("RETDATA");

		if(result != null){
			Map resMap = JSONUtil.toMap(result);
					List listttmp = new ArrayList();
					for(int i=0;i<=retlist.size()-1;i++){
					  Map map=(Map)retlist.get(i);
						if(XINGMING!=null && !XINGMING.equals("")){
							if(map.get("XINGMING")==null || map.get("XINGMING").equals("")){
								continue;
							}else if(!XINGMING.equals(map.get("XINGMING").toString())){
								continue;
							}
						}
						
						if(JCQK!=null && !JCQK.equals("")){
							if(map.get("JCQK")==null || map.get("JCQK").equals("")){
								continue;
							}else if(!JCQK.equals(map.get("JCQK").toString())){
								continue;
							}
						}
						if(ZJHM!=null && !ZJHM.equals("")){
							if(map.get("ZJHM")==null || map.get("ZJHM").equals("")){
								continue;
							}else if(!ZJHM.equals(map.get("ZJHM").toString())){
								continue;
							}	
						}
						if(GRZH!=null && !GRZH.equals("")){
							if(map.get("GRZH")==null || map.get("GRZH").equals("")){
								continue;
							}else if(!GRZH.equals(map.get("GRZH").toString())){
								continue;
							}	
						}
						//
						listttmp.add(map);
					}
					map.put("code", 0); 
					map.put("msg", resMap.get("RETURNDESC"));
					map.put("data",listttmp);
					response.setHeader("Content-type", "text/html;charset=UTF-8");
					response.setCharacterEncoding("UTF-8");
					String jsonString = JSONUtil.ToJsongString2(map);
					PrintWriter pw = response.getWriter();
					pw.write(jsonString);
		}
		}
		return null;
	}
	@RequestMapping("/hfjcbj")
	@ResponseBody
	public String hfjcbj(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String GRZH,String JCQK,String XINGMING,String ZJHM) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		Map reqMap = new HashMap();
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ126");
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setDWZH(sessionIn.getDWZH());
		b.setRQJCQK("停缴");
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		if(retMap.get("RETURNCODE").equals("100")){
		retMap = (Map) retMap.get("body");
    	List retlist = (List)retMap.get("RETDATA");
		for (int i = 0; i < retlist.size(); i++) {
			
			Map map = (Map) retlist.get(i);
			map.put("DWZH", retMap.get("DWZH").toString());
			   
			
		}
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
					List listttmp = new ArrayList();
					for(int i=0;i<=retlist.size()-1;i++){
					  Map map=(Map)retlist.get(i);
						if(GRZH!=null && !GRZH.equals("")){
							if(map.get("GRZH")==null || map.get("GRZH").equals("")){
								continue;
							}else if(!GRZH.equals(map.get("GRZH").toString())){
								continue;
							}
						}
						//
						listttmp.add(map);
					}
					map.put("code", 0); 
					map.put("msg", resMap.get("RETURNDESC"));
					map.put("data",listttmp);
					response.setHeader("Content-type", "text/html;charset=UTF-8");
					response.setCharacterEncoding("UTF-8");
					String jsonString = JSONUtil.ToJsongString2(map);
					PrintWriter pw = response.getWriter();
					pw.write(jsonString);
		}
		}
		return null;
	}
	@RequestMapping("/tzjcbj")
	@ResponseBody
	public String tzjcbj(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String GRZH,String JCQK,String XINGMING,String ZJHM) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		Map reqMap = new HashMap();
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ126");
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setDWZH(sessionIn.getDWZH());
		b.setRQJCQK("缴存");
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		if(retMap.get("RETURNCODE").equals("100")){
		retMap = (Map) retMap.get("body");
    	List retlist = (List)retMap.get("RETDATA");
		for (int i = 0; i < retlist.size(); i++) {
			
			Map map = (Map) retlist.get(i);
			map.put("DWZH", retMap.get("DWZH").toString());
			   
			
		}
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
					List listttmp = new ArrayList();
					for(int i=0;i<=retlist.size()-1;i++){
					  Map map=(Map)retlist.get(i);
						if(GRZH!=null && !GRZH.equals("")){
							if(map.get("GRZH")==null || map.get("GRZH").equals("")){
								continue;
							}else if(!GRZH.equals(map.get("GRZH").toString())){
								continue;
							}
						}
						//
						listttmp.add(map);
					}
					map.put("code", 0); 
					map.put("msg", resMap.get("RETURNDESC"));
					map.put("data",listttmp);
					response.setHeader("Content-type", "text/html;charset=UTF-8");
					response.setCharacterEncoding("UTF-8");
					String jsonString = JSONUtil.ToJsongString2(map);
					PrintWriter pw = response.getWriter();
					pw.write(jsonString);
		}
		}
		return null;
	}
	@RequestMapping("/qrbj")
	@ResponseBody
	public String qrbj(HttpServletRequest request,HttpSession session, HttpServletResponse response ,String DWJCBL,String SJHM,String GRJCJS,String GRJCBL, String limit ,String GRZH,String JCQK,String XINGMING,String ZJHM,String XINGBIE) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		Map reqMap = new HashMap();
		OpenKey p=new OpenKey();
		//接口编码
//		XINGMING =new String(XINGMING.getBytes("iso8859-1"),"utf-8");
		reqMap.put("AUTHORITY", "YBGJJ157");
		BODY b=new BODY();
		//接口参数
		b.setBGLB("1");
		b.setXINGBIE(XINGBIE);
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setXINGMING(XINGMING);
		b.setDWJCBL(DWJCBL);
		b.setGRJCBL(GRJCBL);
		b.setGRZH(GRZH);
		b.setZJHM(ZJHM);
		b.setSJHM(SJHM);
		b.setGRJCJS(GRJCJS);
		
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		if(result!=null){
		retMap = (Map) retMap.get("body");
			Map resMap = JSONUtil.toMap(result);
			if(result!=null){
				//List resList = JSONUtil.toList(resMap.get("body").toString());
				//map.put("count", resList.size());
				map.put("code", 0); 
				map.put("msg", resMap.get("RETURNDESC"));
				map.put("data", retMap);
				
				response.setHeader("Content-type", "text/html;charset=UTF-8");
				response.setCharacterEncoding("UTF-8");
				String jsonString = JSONUtil.ToJsongString2(map);
				PrintWriter pw = response.getWriter();
				pw.write(jsonString);
		}
		}
		return null;
	}
	@RequestMapping("/tj")
	@ResponseBody
	public String tj(HttpServletRequest request,HttpSession session, HttpServletResponse response ,String DWJCBL,String SJHM,String GRJCJS,String GRJCBL, String limit ,String t,String z,String x,String g) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		Map reqMap = new HashMap();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ160");

		String tj=t.substring(0,7);
		String tjsj=tj.replace("-", "");
		BODY b=new BODY();
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setXINGMING(x);
		b.setGRZH(g);
		b.setZJHM(z);
		b.setNY(tjsj);
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		if(result!=null){
		retMap = (Map) retMap.get("body");
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
				//List resList = JSONUtil.toList(resMap.get("body").toString());
				//map.put("count", resList.size());
				map.put("code", 0); 
				map.put("msg", resMap.get("RETURNDESC"));
				map.put("data", retMap);
				
				response.setHeader("Content-type", "text/html;charset=UTF-8");
				response.setCharacterEncoding("UTF-8");
				String jsonString = JSONUtil.ToJsongString2(map);
				PrintWriter pw = response.getWriter();
				pw.write(jsonString);
		}
		}
		return null;
	}
	@RequestMapping("/hf")
	@ResponseBody
	public String hf(HttpServletRequest request,HttpSession session, HttpServletResponse response ,String DWJCBL,String SJHM,String GRJCJS,String GRJCBL, String limit ,String t,String z,String x,String g) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		Map reqMap = new HashMap();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ161");
		//x =new String(x.getBytes("iso8859-1"),"utf-8");
		String tj=t.substring(0,7);
		String tjsj=tj.replace("-", "");
		
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setXINGMING(x);
		b.setGRZH(g);
		b.setZJHM(z);
		b.setNY(tjsj);
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		retMap = (Map) retMap.get("body");
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
			if(result!=null){
				//List resList = JSONUtil.toList(resMap.get("body").toString());
				//map.put("count", resList.size());
				map.put("code", 0); 
				map.put("msg", resMap.get("RETURNDESC"));
				map.put("data", retMap);
				
				response.setHeader("Content-type", "text/html;charset=UTF-8");
				response.setCharacterEncoding("UTF-8");
				String jsonString = JSONUtil.ToJsongString2(map);
				PrintWriter pw = response.getWriter();
				pw.write(jsonString);
			}
		}
		return null;
	}
	@RequestMapping("/hjxz")
	@ResponseBody																				
	public String xz(HttpServletRequest request,HttpSession session, HttpServletResponse response ,String xingming,String zjhm,String dwjce,String grjce, String jcksny ,String sjhm,String dwyx,String jtysr,String gddhhm,String zjlx,String hyzk,String zy,String zc,String zw,String xl,String jtzz,String kahao,String xingbie) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		
		Map reqMap = new HashMap();
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ159");
		reqMap.put("OpenKey",sessionIn.getKEY());
		//接口参数
		//reqMap.put("XINGMING",xingming);
		b.setXINGMING(xingming);
		//reqMap.put("DWZH",sessionIn.getDWZH());
		b.setDWZH(sessionIn.getDWZH());
		//reqMap.put("ZJHM",zjhm);
		b.setZJHM(zjhm);
		//reqMap.put("DWJCE",dwjce);
		b.setDWJCE(dwjce);
		//reqMap.put("GRJCE",grjce);
		b.setGRJCE(grjce);
		if(kahao==null)
			b.setKAHAO("");
		else
			b.setKAHAO(kahao);
		b.setXINGBIE(xingbie);
		//reqMap.put("CJNY",jcksny);
		b.setCJNY(jcksny);
		//reqMap.put("SJHM",sjhm);
		b.setSJHM(sjhm);
		//reqMap.put("DWYB",dwyx);
		b.setDWYB(dwyx);
		//reqMap.put("JTYSR",jtysr);
		b.setJTYSR(jtysr);
		//reqMap.put("JBRGDDHHM",gddhhm);
		b.setJBRGDDHHM(gddhhm);
		//reqMap.put("ZJLX",zjlx);
		b.setZJLX(zjlx);
		//reqMap.put("HYZK",hyzk);
		b.setHYZK(hyzk);
		//reqMap.put("ZY",zy);
		b.setZY(zy);
		//reqMap.put("ZC",zc);
		b.setZC(zc);
		//reqMap.put("ZW",zw);
		b.setZW(zw);
		//reqMap.put("XL",xl);
		b.setXL(xl);
		//reqMap.put("JTZZ",jtzz);
		b.setJTZZ(jtzz);
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		if(result!=null){
		retMap = (Map) retMap.get("body");
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
				//List resList = JSONUtil.toList(resMap.get("body").toString());
				//map.put("count", resList.size());
				map.put("code", 0); 
				map.put("msg", resMap.get("RETURNDESC"));
				map.put("data", retMap.get("RETDATA"));
				
				response.setHeader("Content-type", "text/html;charset=UTF-8");
				response.setCharacterEncoding("UTF-8");
				String jsonString = JSONUtil.ToJsongString2(map);
				PrintWriter pw = response.getWriter();
				pw.write(jsonString);
		}
		}
		return null;
	}
	@RequestMapping("/xlhx")
	@ResponseBody
	public String cxxlk(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String id,String start,String end) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		OpenKey p=new OpenKey();
		Map reqMap = new HashMap();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ158");
		//接口参数
		
		reqMap.put("OpenKey",sessionIn.getKEY());
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		if(retMap.get("RETURNCODE").equals("100")){
		retMap = (Map) retMap.get("body");
		List list = (List)retMap.get("RETDATA");
		List listttmp = new ArrayList();//容器
		for(int i=0;i<list.size();i++){
			  List a=(List) list.get(i);
			  listttmp.add(a);
		}
		List hy=(List) listttmp.get(0);
		List zy=(List) listttmp.get(1);
		List zc=(List) listttmp.get(2);
		List zw=(List) listttmp.get(3);
		List xl=(List) listttmp.get(4);
		List JCYH=(List) listttmp.get(5);
    	List retlist = (List)retMap.get("RETDATA");
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
				//List resList = JSONUtil.toList(resMap.get("body").toString());
				//map.put("count", resList.size());
				map.put("code", 0); 
				map.put("msg", resMap.get("RETURNDESC"));
				map.put("data", listttmp.get(0));
				map.put("data1", listttmp.get(1));
				map.put("data2", listttmp.get(2));
				map.put("data3", listttmp.get(3));
				map.put("data4", listttmp.get(4));
				map.put("data5", listttmp.get(5));
				response.setHeader("Content-type", "text/html;charset=UTF-8");
				response.setCharacterEncoding("UTF-8");
				String jsonString = JSONUtil.ToJsongString2(map);
				PrintWriter pw = response.getWriter();
				pw.write(jsonString);
		}
		}
		return null;
	}
	
	
	@RequestMapping("/tpsc")
	@ResponseBody
	 public String upload( HttpServletRequest request, String name,@RequestParam("files") MultipartFile[] files,HttpSession session,HttpServletResponse response,
String isphoto,String ftype ,String  ytype ,String uid 
			 ,String yid ,String btype ) throws IOException{  
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());

	        String path = request.getSession().getServletContext().getRealPath("upload")+"/image";  
	        String fileName="";
	        for(int i=0;i<files.length;i++){
	        	fileName = files[i].getOriginalFilename();
	        	
	        
	      //获取到上传文件的名字
	        //System.out.println(file.getName()+"2222");获取到file
	        //file.getSize();获取到上传文件的大小
	        		String a="";
					String b="";
					String c="";
					String d="";
					String e="";
	        String NAME= System.getProperty ("os.name");
	        if(isphoto.equals("0"))
        		a="/photo";
        	else
        		a="/file";
        	b="/"+ftype;
        	if(ftype.equals("1"))
        		c="/"+uid.substring(0,4)+"/"+uid.substring(4,8)+"/"+uid.substring(8,12);
        	else
        		c="/"+uid.substring(0,3)+"/"+uid.substring(3,6);
        	d="/"+yid;
        	e="/"+btype;
	        if (NAME.substring(0, 7).equals("Windows"))
	        {	
	        	path=Constant.PK_FILEPATH+b+c+d+e;
	        }
	        else{
	        	path=Constant.PK_FILEPATH+b+c+d+e;
	        }
	        	
	        SimpleDateFormat s=new SimpleDateFormat("yyyyMMddHHmmSS");
	        String[] l=fileName.split("\\.");
	        File dir = new File(path,l[0]+s.format(new Date())+"."+l[1] );
	        if(!dir.exists()){  
	            dir.mkdirs();  
	        }  
	        files[i].transferTo(dir);  
	        }
	        //MultipartFile自带的解析方法  
			return null; 
	    }
	
	@RequestMapping("/tpck")
	@ResponseBody
	public  void ck( HttpServletRequest request,HttpServletResponse response,String ID,String pa,String type) throws IOException {   
        // This is the path where the file's name you want to take.  
		String NAME= System.getProperty ("os.name");
		String path="";///1/1234/4567/8901/
		StringBuilder sb=new StringBuilder(pa);
		sb.insert(0,"1");
				sb.insert(0, "/");
				sb.insert(2, "/");
				sb.insert(7, "/");
				sb.insert(12, "/");
			path =  Constant.PK_FILEPATH+sb+"/"+ID+"/"+type;
        File file = new File(path);   
        File[] array = file.listFiles();   
        List li=getFile(path);   
        response.setHeader("Content-type", "text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		String jsonString = JSONUtil.ToJsongString2(li);
		PrintWriter pw = response.getWriter();
		pw.write(jsonString);
    }   
       
    private static List getFile(String path){   
        // get file list where the path has   
        File file = new File(path);   
        // get the folder list   
        File[] array = file.listFiles();   
          List l=new ArrayList();
        for(int i=0;i<array.length;i++){   
            if(array[i].isFile()){   
                // only take file name   
            	l.add(array[i].getName());
            }else if(array[i].isDirectory()){   
                getFile(array[i].getPath());   
            }   
        }
        return l;
    }   
    
    @RequestMapping("/bgjs")
	@ResponseBody
	public String bgjs(HttpServletRequest request,HttpSession session, HttpServletResponse response ,String DWJCBL,String SJHM,String GRJCJS,String GRJCBL, String limit ,String GRZH,String JCQK,String XINGMING,String ZJHM,String XINGBIE,String DWJCE,String GRJCE,String NIANYUE) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		Map reqMap = new HashMap();
		OpenKey p=new OpenKey();
		//接口编码
//		XINGMING =new String(XINGMING.getBytes("iso8859-1"),"utf-8");
		reqMap.put("AUTHORITY", "YBGJJ157");
		BODY b=new BODY();
		//接口参数
		b.setBGLB("2");
		b.setXINGBIE(XINGBIE);
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setXINGMING(XINGMING);
		b.setDWJCBL(DWJCBL);
		b.setGRJCBL(GRJCBL);
		b.setGRZH(GRZH);
		b.setZJHM(ZJHM);
		b.setSJHM(SJHM);
		b.setGRJCJS(GRJCJS);
		b.setDWJCE(DWJCE);
		b.setGRJCE(GRJCE);
		NIANYUE=NIANYUE.replace("-", "");
		b.setSXSJ(NIANYUE+"01");
		reqMap.put("BODY",b);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		if(result!=null){
		retMap = (Map) retMap.get("body");
			Map resMap = JSONUtil.toMap(result);
			if(result!=null){
				//List resList = JSONUtil.toList(resMap.get("body").toString());
				//map.put("count", resList.size());
				map.put("code", 0); 
				map.put("msg", resMap.get("RETURNDESC"));
				map.put("data", retMap);
				
				response.setHeader("Content-type", "text/html;charset=UTF-8");
				response.setCharacterEncoding("UTF-8");
				String jsonString = JSONUtil.ToJsongString2(map);
				PrintWriter pw = response.getWriter();
				pw.write(jsonString);
		}
		}
		return null;
	}
    
    @RequestMapping("/bgh")
  	@ResponseBody
  	public String bgh(HttpServletRequest request,HttpSession session, HttpServletResponse response ,String DWJCBL,String SJHM,String GRJCJS,String GRJCBL, String limit ,String GRZH,String JCQK,String XINGMING,String ZJHM,String XINGBIE,String DWJCE,String GRJCE) throws IOException{
  		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
  		//读取配置文件路劲
  		String interfaceUrl = ReadConfig.readValue();
  		Map reqMap = new HashMap();
  		OpenKey p=new OpenKey();
  		//接口编码
//  		XINGMING =new String(XINGMING.getBytes("iso8859-1"),"utf-8");
  		reqMap.put("AUTHORITY", "YBGJJ205");
  		BODY b=new BODY();
  		//接口参数
  		reqMap.put("OpenKey",sessionIn.getKEY());
  		b.setZJHM(ZJHM);
  		reqMap.put("BODY",b);
  		String  result = p.getOpenKey(reqMap, session);
  		Map retMap = JSONUtil.toMap(result);
  		if(result!=null){
  		retMap = (Map) retMap.get("body");
  			Map resMap = JSONUtil.toMap(result);
  			if(result!=null){
  				//List resList = JSONUtil.toList(resMap.get("body").toString());
  				//map.put("count", resList.size());
  				map.put("code", 0); 
  				map.put("msg", resMap.get("RETURNDESC"));
  				map.put("data", retMap.get("RETDATA"));
  				
  				response.setHeader("Content-type", "text/html;charset=UTF-8");
  				response.setCharacterEncoding("UTF-8");
  				String jsonString = JSONUtil.ToJsongString2(map);
  				PrintWriter pw = response.getWriter();
  				pw.write(jsonString);
  		}
  		}
  		return null;
  	}
    @RequestMapping("/bgqc")
	@ResponseBody
	//汇缴清册编辑
	public String bgqc(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String id,String start,String end,String XINGMING,String ZJHM) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		Map reqMap = new HashMap();
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ206");
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setDWZH(sessionIn.getDWZH());
		reqMap.put("BODY",b);
		if(XINGMING==null)
			b.setXINGMING("");
		else
			b.setXINGMING(XINGMING);
		if(ZJHM==null)
			b.setZJHM("");
		else
			b.setZJHM(ZJHM);
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		List retlist=new ArrayList();
		if(retMap.get("RETURNCODE").equals("100")){
		retMap = (Map) retMap.get("body");
    	 retlist = (List)retMap.get("RETDATA");
//		for (int i = 0; i < retlist.size(); i++) {		
//			Map map = (Map) retlist.get(i);
//			map.put("DWMC", retMap.get("DWMC").toString());	
//		}
		}
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
			List listttmp = new ArrayList();
			map.put("code", 0); 
			map.put("msg", resMap.get("RETURNDESC"));
			map.put("data",retlist);
			response.setHeader("Content-type", "text/html;charset=UTF-8");
			response.setCharacterEncoding("UTF-8");
			String jsonString = JSONUtil.ToJsongString2(map);
			PrintWriter pw = response.getWriter();
			pw.write(jsonString);
		
	}
		return null;
	}
    @RequestMapping("/bghxx")
	@ResponseBody
	//汇缴清册编辑
	public String bghxx(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String id,String start,String end,String XINGMING,String NIANYUE) throws IOException{
		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
		//读取配置文件路劲
		String interfaceUrl = ReadConfig.readValue();
		Map reqMap = new HashMap();
		BODY b=new BODY();
		OpenKey p=new OpenKey();
		//接口编码
		reqMap.put("AUTHORITY", "YBGJJ210");
		//接口参数
		reqMap.put("OpenKey",sessionIn.getKEY());
		b.setDWZH(sessionIn.getDWZH());
		reqMap.put("BODY",b);
		NIANYUE=NIANYUE.replace("-", "");
		b.setSXSJ(NIANYUE+"01");
		String  result = p.getOpenKey(reqMap, session);
		Map retMap = JSONUtil.toMap(result);
		List retlist=new ArrayList();
		if(retMap.get("RETURNCODE").equals("100")){
		retMap = (Map) retMap.get("body");
    	 retlist = (List)retMap.get("RETDATA");
//		for (int i = 0; i < retlist.size(); i++) {		
//			Map map = (Map) retlist.get(i);
//			map.put("DWMC", retMap.get("DWMC").toString());	
//		}
		}
		if(result != null){
			Map resMap = JSONUtil.toMap(result);
			List listttmp = new ArrayList();
			map.put("code", 0); 
			map.put("msg", resMap.get("RETURNDESC"));
			map.put("data",retlist);
			response.setHeader("Content-type", "text/html;charset=UTF-8");
			response.setCharacterEncoding("UTF-8");
			String jsonString = JSONUtil.ToJsongString2(map);
			PrintWriter pw = response.getWriter();
			pw.write(jsonString);
		
	}
		return null;
	}
    
    
    @RequestMapping("/sh")
   	@ResponseBody
   	//汇缴清册编辑
   	public String sh(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String id,String start,String end,String XINGMING,String ZJHM) throws IOException{
   		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
   		//读取配置文件路劲
   		String interfaceUrl = ReadConfig.readValue();
   		Map reqMap = new HashMap();
   		BODY b=new BODY();
   		OpenKey p=new OpenKey();
   		//接口编码
   		reqMap.put("AUTHORITY", "YBGJJ211");
   		//接口参数
   		reqMap.put("OpenKey",sessionIn.getKEY());
   		b.setDWZH(sessionIn.getDWZH());
   		reqMap.put("BODY",b);
   		if(XINGMING==null)
   			b.setXINGMING("");
   		else
   			b.setXINGMING(XINGMING);
   		if(ZJHM==null)
   			b.setZJHM("");
   		else
   			b.setZJHM(ZJHM);
   		String  result = p.getOpenKey(reqMap, session);
   		Map retMap = JSONUtil.toMap(result);
   		List retlist=new ArrayList();
   		retMap = (Map) retMap.get("body");
       	 retlist = (List)retMap.get("RETDATA");
   		if(result != null){
   			Map resMap = JSONUtil.toMap(result);
   			List listttmp = new ArrayList();
   			map.put("code", 0); 
   			map.put("msg", resMap.get("RETURNDESC"));
   			map.put("data",retlist);
   			response.setHeader("Content-type", "text/html;charset=UTF-8");
   			response.setCharacterEncoding("UTF-8");
   			String jsonString = JSONUtil.ToJsongString2(map);
   			PrintWriter pw = response.getWriter();
   			pw.write(jsonString);
   		
   	}
   		return null;
   	}
    @RequestMapping("/delete")
   	@ResponseBody
   	//汇缴清册编辑
   	public String delete(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String ID,String start,String end,String XINGMING,String ZJHM) throws IOException{
   		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
   		//读取配置文件路劲
   		String interfaceUrl = ReadConfig.readValue();
   		Map reqMap = new HashMap();
   		BODY b=new BODY();
   		OpenKey p=new OpenKey();
   		//接口编码
   		reqMap.put("AUTHORITY", "YBGJJ212");
   		//接口参数
   		reqMap.put("OpenKey",sessionIn.getKEY());
   		b.setDWZH(sessionIn.getDWZH());
   		reqMap.put("BODY",b);
   		b.setID(ID);
   		String  result = p.getOpenKey(reqMap, session);
   		Map retMap = JSONUtil.toMap(result);
   		List retlist=new ArrayList();
   		retMap = (Map) retMap.get("body");
       	 retlist = (List)retMap.get("RETDATA");
   		if(result != null){
   			Map resMap = JSONUtil.toMap(result);
   			List listttmp = new ArrayList();
   			map.put("code", 0); 
   			map.put("msg", resMap.get("RETURNDESC"));
   			map.put("data",retlist);
   			response.setHeader("Content-type", "text/html;charset=UTF-8");
   			response.setCharacterEncoding("UTF-8");
   			String jsonString = JSONUtil.ToJsongString2(map);
   			PrintWriter pw = response.getWriter();
   			pw.write(jsonString);
   		
   	}
   		return null;
   	}
    
    @RequestMapping("/xzsh")
   	@ResponseBody
   	//汇缴清册编辑
   	public String xzsh(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String ID,String start,String end,String XINGMING,String ZJHM) throws IOException{
   		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
   		//读取配置文件路劲
   		String interfaceUrl = ReadConfig.readValue();
   		Map reqMap = new HashMap();
   		BODY b=new BODY();
   		OpenKey p=new OpenKey();
   		//接口编码
   		reqMap.put("AUTHORITY", "YBGJJ220");
   		//接口参数
   		reqMap.put("OpenKey",sessionIn.getKEY());
   		b.setDWZH(sessionIn.getDWZH());
   		reqMap.put("BODY",b);
   		b.setID(ID);
   		String  result = p.getOpenKey(reqMap, session);
   		Map retMap = JSONUtil.toMap(result);
   		List retlist=new ArrayList();
   		retMap = (Map) retMap.get("body");
       	 retlist = (List)retMap.get("RETDATA");
   		if(result != null){
   			Map resMap = JSONUtil.toMap(result);
   			List listttmp = new ArrayList();
   			map.put("code", 0); 
   			map.put("msg", resMap.get("RETURNDESC"));
   			map.put("data",retlist);
   			response.setHeader("Content-type", "text/html;charset=UTF-8");
   			response.setCharacterEncoding("UTF-8");
   			String jsonString = JSONUtil.ToJsongString2(map);
   			PrintWriter pw = response.getWriter();
   			pw.write(jsonString);
   		
   	}
   		return null;
   	}
    
    @RequestMapping("/shde")
   	@ResponseBody
   	//汇缴清册编辑
   	public String shde(HttpServletRequest request,HttpSession session, HttpServletResponse response , String limit ,String ID,String start,String end,String XINGMING,String ZJHM) throws IOException{
   		SessionInfo sessionIn = (SessionInfo) session.getAttribute(ConfigUtil.getSessionInfoName());
   		//读取配置文件路劲
   		String interfaceUrl = ReadConfig.readValue();
   		Map reqMap = new HashMap();
   		BODY b=new BODY();
   		OpenKey p=new OpenKey();
   		//接口编码
   		reqMap.put("AUTHORITY", "YBGJJ221");
   		//接口参数
   		reqMap.put("OpenKey",sessionIn.getKEY());
   		b.setDWZH(sessionIn.getDWZH());
   		reqMap.put("BODY",b);
   		b.setID(ID);
   		String  result = p.getOpenKey(reqMap, session);
   		Map retMap = JSONUtil.toMap(result);
   		List retlist=new ArrayList();
   		retMap = (Map) retMap.get("body");
       	 retlist = (List)retMap.get("RETDATA");
   		if(result != null){
   			Map resMap = JSONUtil.toMap(result);
   			List listttmp = new ArrayList();
   			map.put("code", 0); 
   			map.put("msg", resMap.get("RETURNDESC"));
   			map.put("data",retlist);
   			response.setHeader("Content-type", "text/html;charset=UTF-8");
   			response.setCharacterEncoding("UTF-8");
   			String jsonString = JSONUtil.ToJsongString2(map);
   			PrintWriter pw = response.getWriter();
   			pw.write(jsonString);
   		
   	}
   		return null;
   	}
}
